<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/3/15
 * Time: 10:55
 */

namespace App\Http\Controllers\MiniProgramAdmin;


use App\Http\Logics\MiniProgramAdmin\SystemNotifyLogic;
use App\Http\Traits\SystemNotifyTrait;
use App\Http\Controllers\BaseController;
class SystemNotifyController extends BaseController
{
    use SystemNotifyTrait;

    /**
     * @SWG\Post(
     *     path="/systemNotify/create",
     *     tags={"SystemNotify"},
     *     description="发布系统通知",
     *     operationId="createSystemNotify",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥(登陆后需要传该参数)",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="title",
     *         in="query",
     *         description="系统通知标题",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createSystemNotify()
    {
        $title = $this->title;
        $data = [
            'title' => $title
        ];
        $response = SystemNotifyLogic::createSystemNotify($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response(0,'',$response->data);
    }

    /**
     * @SWG\Get(
     *     path="/systemNotify/list",
     *     tags={"SystemNotify"},
     *     description="系统通知列表",
     *     operationId="getSystemNotifyList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥(登陆后需要传该参数)",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="limit",
     *         in="query",
     *         description="分页大小",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getSystemNotifyList()
    {
        $limit = $this->limit;
        $data = [
            'limit' => $limit
        ];
        $response = SystemNotifyLogic::getSystemNotifyList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response(0,'',$response->data);
    }

    /**
     * @SWG\Get(
     *     path="/systemNotify/detail",
     *     tags={"SystemNotify"},
     *     description="系统通知详情",
     *     operationId="detail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥(登陆后需要传该参数)",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="system_notify_id",
     *         in="query",
     *         description="系统通知ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function detail()
    {
        $system_notify_id = $this->system_notify_id;
        $data = [
            'system_notify_id' => $system_notify_id
        ];
        $response = SystemNotifyLogic::detail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/systemNotify/delete",
     *     tags={"SystemNotify"},
     *     description="系统通知删除",
     *     operationId="delete",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥(登陆后需要传该参数)",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="system_notify_id",
     *         in="query",
     *         description="系统通知ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function delete()
    {
        $system_notify_id = $this->system_notify_id;
        $data = [
            'system_notify_id' => $system_notify_id
        ];
        $response = SystemNotifyLogic::delete($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}